import React from 'react';
import {Form, Input, Button, Select, Breadcrumb } from 'antd';
import BreadcrumbNav from '../../../components/BreadcrumbNavBar/breadcrumbNav';

const Index = React.createClass({

  contextTypes: {
    router: React.PropTypes.object
  },

  getInitialState() {
    return {
      item: '房屋装修'
    }
  },

  handleRouter() {
    let path = this.props.location.pathname;
    let state = this.props.location.state;
    let lastPath = path.split('/')[path.split('/').length - 1];
    console.log(lastPath)
    let index = '/landlord/houseDecoration/list';
    let add = '/landlord/houseDecoration/chargeManage/chargeList';
    let chargeAdd = '/landlord/houseDecoration/chargeManage/chargeList';
    let goPathUrl = ( lastPath == 'list' || lastPath == 'houseDecoration') ? add : (lastPath == 'chargeAdd' ? chargeAdd : index);
    this.context.router.push({pathname: goPathUrl,state: {...state}});
  },

  render () {
    let path = this.props.location.pathname;
    let lastPath = path.split('/')[path.split('/').length - 1];
    let routerItem = {
      'list': '列表',
      'houseDecoration': '列表',
      'chargeList': '收费项列表',
      'chargeAdd': '收费项设置',
      'addRoom': '房间新增',
      'roomModify': '房间修改',
      'cost': '消费',
      'roomCost': '消费',
      'historicalCost': '费用历史'
    };
    let txtName = ( lastPath == 'list' || lastPath == 'houseDecoration') ? '收费项设置' : '返回';
    return (
      <div>
        <div className="nav-bar">
          <Breadcrumb separator="-" >
            <Breadcrumb.Item>{this.state.item}</Breadcrumb.Item>
            <Breadcrumb.Item>{routerItem[lastPath]}</Breadcrumb.Item>
          </Breadcrumb>
          <Button className="ant-button" type="primary" htmlType="button" onClick={this.handleRouter}>{txtName}</Button>
        </div>
        <div className="content-wrapper">
          {this.props.children}
        </div>
      </div>
    );
  }
});

export default Index